<?php
    require "config.php";
	
    $usname=$_POST['usrname'];

    $pswd=$_POST['pwd'];
   
    $con = mysql_connect($db_host,$db_user,$db_pass);

    if (!$con){
		die('Could not connect: ' . mysql_error());
    }
    mysql_select_db($db_name, $con);
    
    
    $usname=stripslashes($usname);
    $pswd = stripslashes($pswd);
    $usname = mysql_real_escape_string($usname);
    $pswd = mysql_real_escape_string($pswd);
	
    $sql = "SELECT * FROM register WHERE uname='$usname' and pass='$pswd' ";
    $result= mysql_query($sql);
    $count= mysql_num_rows($result);
	
	$sql2 = "SELECT * FROM register WHERE uname='$usname'";
    $result2= mysql_query($sql2);
	 while($row= mysql_fetch_array($result2))
	{
	 $firstn=$row['fname'];
	 $lastn=$row['lname'];
	
	 }
	
     if($count==1)
	{
	session_start();
	$_SESSION['username']=$usname; 
	 $_SESSION['firstname']= $firstn;
	 $_SESSION['lastname']= $lastn;
   require "search.php";
	}
   else
	{
	echo" Wrong username and password";
      	}
    
       mysql_close($con); 
    

?>
